<?php

   // Create new service for PHP Remoting as Class
   class GoDBHandler {

      function GoDBHandler () {

         // Define the methodTable for this class in the constructor
         $this->methodTable = array(
                "getUsers" => array(
                   "description" => "Return a list of users",
                   "access" => "remote"
                   )
                );
         }


      function getUsers () {

         $mysql = mysql_connect(localhost, "root", "null8fuffzehn");
         mysql_select_db( "gorss" );

         //return a list of all the users
         $Query = "SELECT * from gorss_users";
         $Result = mysql_query( $Query );

         while ($row = mysql_fetch_object($Result)) {
            $ArrayOfUsers[] = $row;
         }

         return( $ArrayOfUsers );
      }
      
      // category count, later for specific user: SELECT * FROM gorss_cats WHERE uid = $uid, should work this way.
      function getCatCount() {
       	$mysql = mysql_connect(localhost, "root", "null8fuffzehn");
      	mysql_select_db("gorss");
      	$query = "SELECT * FROM gorss_cats";
      	$result = mysql_query($query);
      	while($row = mysql_fetch_object($result)) {
      		$catcount[] = $row;
      	}
      	return($catcount);   	
      }
      
      // reading feeds from a specific category:
      function getFeedsFromCategory($cat) {
      	$mysql = mysql_connect(localhost, "root", "null8fuffzehn");
      	mysql_select_db("gorss");
      	$query = "SELECT * FROM gorss_feeds WHERE fcat = $cat";
      	$result = mysql_query($query);
      	while($row = mysql_fetch_object($result)) {
      		$ArrayOfFeeds[] = $row;
      	}
      	return($ArrayOfFeeds);
      }
	  
  
}
?>